package yxy.game.pm2.bean.module.rank.active;

import org.joda.time.DateTime;

import yxy.game.pm2.bean.area.AreaBean;
import yxy.game.pm2.bean.module.AreaModule;

/**
 * 副本关卡排行榜
 * @author Dell
 *
 */
public class ActiveChongBangRankRush extends PlayerActiveRankModule{
	
	public ActiveChongBangRankRush(AreaBean areaBean, int type) {
		super(areaBean, type);
	}
	
	@Override
	protected boolean reconsitution() {
		return false;  
	}

	@Override
	public String rankName() {
		return "RUSH:";
	}

	@Override
	protected long valuePlastic(long value) {
		return value * 10000000000000L + (10000000000000L - DateTime.now().getMillis());// 13位时间戳长度
	}

	@Override
	protected long valueRestore(long score) {
		return score / 10000000000000L;
	}


	static public void reset() {
	}

	static public void delete(int areaid, int type) {
		String infokey = "AREA:" + areaid + ":RANK:RUSH:" + type + ":INFO";
		redis().client().getKeys().deleteByPattern(infokey);
		
		String sortkey = "AREA:" + areaid + ":RANK:RUSH:" + type + ":SORT";
		redis().client().getKeys().deleteByPattern(sortkey);
	}
	
	/**
	 * 累加数据值
	 * @param playercode
	 * @param addvalue
	 */
	static public void addRankRush(String playercode, int addvalue, int type) {
		AreaBean areaBean = AreaModule.area(playercode);
		ActiveChongBangRankRush rr = new ActiveChongBangRankRush(areaBean, type);
		rr.addAndSet(playercode, addvalue);	
	}
	
	static public ActiveChongBangRankRush getRank(String playerCode, int type) {
		AreaBean areaBean = AreaModule.area(playerCode);
		return new ActiveChongBangRankRush(areaBean, type);
	}
	
}
